import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import AppLayout from '@/layout/AppLayout.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView,
    },
    {
      path: '/about',
      name: 'about',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/backend/CourseManage.vue'),
    },
    {
      path:'/backend/manage',
      name:'manage',
      component:() => import('../views/backend/ManageView.vue')
    },
    {
      path:'/course',
      name:'course',
      component:() => import('../views/CourseDetail.vue')
    },
    {
      path:'/introduction',
      name:'introduction',
      component:() => import('../views/Introduction.vue')
    },
    {
      path:'/backend/video-add',
      name:'video-add',
      component:() => import('../views/backend/AddVideo.vue')
    },
    {
      path:'/backend/course-add',
      name:'course-add',
      component:() => import('../views/backend/AddCourse.vue')
    },
    {
      path: '/',
      component: AppLayout,
      redirect: '/backend/dashboard',
      children: [
        {
          path: '/backend/dashboard',
          name: 'Dashboard',
          component: () => import('../views/backend/Dashboard.vue'),
          meta: { title: '仪表盘' }
        },
        {
          path: '/backend/empty',
          name: 'Empty',
          component: () => import('../views/backend/Empty.vue'),
          meta: { title: '空白页面' }
        },
        {
          path:'/backend/course',
          name:'back-course',
          component:() => import('../views/backend/CourseView.vue'),
          meta: { title: '课程管理' }
        },
        {
          path: '/backend/course-edit/:id',
          name: 'course-edit',
          component: () => import('../views/backend/CourseEdit.vue'),
          meta: { title: '修改课程' }
        },
        {
          path: '/backend/chapter-edit/:id',
          name: 'chapter-edit',
          component: () => import('../views/backend/ChapterEdit.vue'),
          meta: { title: '修改章节' }
        },
        {
          path: '/backend/course-show/:id',
          name: 'course-show',
          component: () => import('../views/backend/CourseManage.vue'),
          meta: { title: '课程详情' }
        },
      ]
    },
  ],
})

export default router
